#include "Gp.h"

namespace gp
{
	static const cr::size_t g_cNumScratchParameters = 8192;
	static Parameter g_scratchParameters[g_cNumScratchParameters];
	static Parameter* g_pCurScratchParam = g_scratchParameters;
	static cr::uint32_t g_numParamsAllocated = 0;

	namespace ParameterBlockScratchAllocator
	{
		void		ResetScratchParams()
		{
			g_pCurScratchParam = g_scratchParameters;
			g_numParamsAllocated = 0;
		}

		Parameter*	AllocateScratch(cr::size_t numParams)
		{
			CR_ASSERT((g_pCurScratchParam + numParams) < (g_scratchParameters + g_cNumScratchParameters));
			Parameter* pParams = g_pCurScratchParam;
			g_pCurScratchParam += numParams;
			g_numParamsAllocated += numParams;
			return pParams;
		}
	}
}